package com.kadoufall.recommender.web;

import com.kadoufall.recommender.dao.NewsRepository;
import com.kadoufall.recommender.dao.UserRepository;
import com.kadoufall.recommender.model.News;
import com.kadoufall.recommender.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping(value = "/news")
public class NewsController {
    @Autowired
    NewsRepository newsRepository;

    @RequestMapping(value = "/find/{newsId}", method = RequestMethod.GET)
    public News find(@PathVariable long newsId) {
//        System.out.println("in CF recommend");
        return newsRepository.findById(newsId);
    }

    @RequestMapping(value = "/search/{keywords}", method = RequestMethod.GET)
    public List<News> search(@PathVariable String keywords) {
//        System.out.println("in CF recommend");
        return newsRepository.searchInTitle(keywords);
    }

}
